package com.example.demo.client.web;

import com.example.dubbo.demo.server.modules.message.entity.MessageEntity;
import com.example.dubbo.demo.server.modules.message.service.MessageService;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author dzii
 */
@RestController
public class DubboDemoController {

    @DubboReference
    private MessageService messageService;

    @GetMapping("/message/{id}")
    public String getMessage(@PathVariable Long id) {
        MessageEntity message = messageService.getById(id);
        return message == null ? "NOT FOUND" : message.getContent();
    }

}
